import { ActionConstant } from '../actions/search_action';
import { initState } from './search_reducer';
import { Map } from 'immutable'

export default function result_refine(state, action) {
    switch (action.type) {
        case ActionConstant.type_select_result_filetype:
            let new_content = state.get('content').set('file_type', action.index)
            return state.set('content', new_content)
            break;
        case ActionConstant.type_select_result_last_update:
            new_content = state.get('content').set('last_update', action.index)
            return state.set('content', new_content)
            break;
        case ActionConstant.type_clear_result:
            return Map(initState.result_refine);
        default:
            if(!state)
                return Map(initState.result_refine);
            return state
    }
}